#include "head.h"

/*int server_init(shared_resource_t* pshared_resource, pool_data_t* pool_data, int* socket_fd, MYSQL** mysql){
    // 服务端的 ip 和 端口
    char* ip = "192.168.72.128";
    char* port = "8080";
    
    // 数据库的 信息
    char* user = "root";
    char* password = "123456";
    char* data_base = "myDataBase";
*/
int server_init(config *config_info,shared_resource_t* pshared_resource, pool_data_t* pool_data, int* socket_fd, MYSQL** mysql){
    char* ip = config_info -> server_ip;
    char* port = config_info -> server_port;
    
    // 数据库的 信息
    char* user = config_info -> data_base_user;
    char* password = config_info -> data_base_pwd;
    char* data_base = config_info -> data_base_name;
    
    // 子线程的个数
    const int num = config_info -> pthread_count;

    tcp_init(socket_fd, ip, port);
    shared_resource_init(pshared_resource, user, password, data_base);
    pool_init(pool_data, num, pshared_resource);

    *mysql = mysql_init(NULL);
    if(!mysql_real_connect(*mysql,LOCAL_HOST,user,password,data_base,0,NULL,0)){
        printf( "server_init in 22 %s\n", mysql_error(*mysql));
    }
    else{
        puts("所有初始化完成");
        puts("数据库连接成功");
    }

    
    


    return 0;

}
